#@layout()

#define script()
<script>

    function find(id) {
        $.ajax({
            url: "http://47.105.208.60:8080/wechat-api/category/findByPid?pid=" + id
            //url: "http://localhost:8080/wechat-api/category/findByPid?pid=" + id
            , dataType: 'json'
            , type: 'get'
            , success: function (data) {

                if (data.code == 0) {
                    $("h5").html("");
                    var infos = data.info;
                    $(infos).each(function () {

                        var content = "<button class='button' onclick='findAll(\"" + this.id + "\")' style='margin-left: 50px'>" + this.title + "</button>";
                        $("h5").append($(content));
                    })
                } else {
                    alert("操作失败");//请求传输失败回调函数
                }
            }
            , error: function (msg) {
                console.log("----------")
                alert(msg); //错误信息

            }

        })
    }
    function findAll(id) {
        $.ajax({
            url: "http://47.105.208.60:8080/wechat-api/article/selectsum?categoryId=" + id
            //url: "http://localhost:8080/wechat-api/article/selectsum?categoryId=" + id
            , dataType: 'json'
            , type: 'get'
            , success: function (data) {

                if (data.code == 0) {
                    $("h5").html("");
                    var infos = data.info;
                    $(infos).each(function () {

                        var content = "<tr id='tr' class='tr'>"+
                            "<td>" + this.sum + "</td>"+
                            "<td>" + this.id + "</td>"+
                            "<td>" + this.title + "</td>"+
                            "<td>" + this.nickname + "</td>"+
                            "<td><button onclick='addyear(\"" + this.id + "\")'>加入年赛</button><button onclick='addshow(\"" + this.id + "\")'>加入巡展</button></td>"+
                            "</tr>";
                        $("h5").append($(content));
                    })
                } else {
                    alert("操作失败");//请求传输失败回调函数
                }
            }
            , error: function (msg) {
                console.log("----------")
                alert(msg); //错误信息

            }

        })
    }
    function addyear(id) {
        $.ajax({
            url: "http://47.105.208.60:8080/wechat-api/mapping/addyear?articleId=" + id
            //url: "http://localhost:8080/wechat-api/mapping/addyear?articleId=" + id
            , dataType: 'json'
            , type: 'get'
            , success: function (data) {

                if (data.code == 0) {
                   alert("加入成功");
                } else {
                    alert("操作失败");//请求传输失败回调函数
                }
            }
            , error: function (msg) {
                console.log("----------")
                alert(msg); //错误信息

            }

        })
    }
    function addshow(id) {
        $.ajax({
            url: "http://47.105.208.60:8080/wechat-api/mapping/addshow?articleId=" + id
            //url: "http://localhost:8080/wechat-api/mapping/addshow?articleId=" + id
            , dataType: 'json'
            , type: 'get'
            , success: function (data) {

                if (data.code == 0) {
                    alert("加入成功");
                } else {
                    alert("操作失败");//请求传输失败回调函数
                }
            }
            , error: function (msg) {
                console.log("----------")
                alert(msg); //错误信息

            }

        })
    }

</script>

#end

#define content()
<div class="content-wrapper">
    <section class="content-header">
        <h1>
            作品评选
        </h1>
    </section>

    <section class="content-header text-tap">
    </section>
    <div>
        <div class="box box-primary">
            <section class="content-header">
                <h1>
                    <h4>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        <button class="button" onclick="find('101')">季赛</button>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        <button class="button" onclick="find('102')">主题赛</button>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        <button class="button" onclick="findAll('103')">年赛</button>
                    </h4>
                    <hr/>
                    <h5>

                    </h5>
                </h1>

            </section>
            <div class="box-body ">

                <table class="table table-striped">
                    <thead>
                    <tr>
                        <th>点赞数量</th>
                        <th>参赛编号</th>
                        <th>作品名称</th>
                        <th>作者</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody id="year">


                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
#end
